< previous page page_754 next page >

Page 754
0754-01.jpg
Figure 33.7
A sample FTP session on the Vax VMS system.
If you have used a DOS prompt, then you can understand how FTP works. FTP allows you to change the current directory, display a file list, and copy filesjust like you would at a DOS prompt. The major difference is that you are browsing a directory structure on a remote machine. The commands are also slightly different. FTP's get and put commands are used to retrieve and send files to and from the remote machine.
Because FTP is a standard protocol used on many platforms (UNIX, Windows, AS/400, and so on), it is ideal for transferring data between machines. The Internet Transfer control provides an easy way to do this from Visual Basic. In this section, we will create a simple program that retrieves a file from an FTP server.
To begin, let's build on the example from the previous section. Create the sample project as described, adding an additional command button, cmdGetFile. The code for cmdGetFile is shown in Listing 33.5.
Listing 33.5 INETDEMO.ZIPUsing FTP with the Internet Transfer Control
Private Sub cmdGetFile_Click()
    Me.Cls
    Inet1.protocol = icFTP
    Inet1.UserName = "anonymous"
    Inet1.Password = "guest@"
    Inet1.Execute "ftp.microsoft.com", "pwd"
    While Inet1.StillExecuting
        DoEvents
    Wend
    
    Inet1.Execute , "dir *.txt"
    While Inet1.StillExecuting
        DoEvents
    Wend
    
    Inet1.Execute , "GET dirmap.txt c:\dirmap.txt"
    While Inet1.StillExecuting

 
< previous page page_754 next page >